import allure
from page_object.roncoo_login import RoncooLogin
from utils.timer import sleep
from page_element.el_transaction_management import payment_order
import logging
from pytest_assume.plugin import assume



class RoncooTransactionManagement(RoncooLogin):

    def login(self):
        # 前置添加：已登录
        with allure.step(f"正在登录..."):
            self.roncoo_login()
        with allure.step(f"点击交易管理菜单:"):
            self.click(payment_order.transaction_management_click)

    def payment_order_search(self):
        self.login()
        self.driver.implicitly_wait(10)
        with allure.step(f"点击支付订单管理菜单:"):
            sleep(2)
            self.click(payment_order.payment_order_click)
        with allure.step(f"输入商户订单号:"):
            self.send_keys(payment_order.user_order_input, '1734045687143')
        with allure.step(f"选择支付方式:"):
            self.select_by_value(payment_order.select_way, payment_order.value_way_wx)
        with allure.step(f"点击查询按钮:"):
            self.click(payment_order.query_btn)
        # 隐式等待---断言
        self.driver.implicitly_wait(10)
        with allure.step('验证成功查询到商户编号对应的商户信息'):
            dy = self.text(payment_order.dy_user_name)
            assume('mobile' in dy, f"断言失败(验证失败): 期望包含'mobile'，实际得到'{dy}'")
            dy_page = self.text(payment_order.page_info)
            assume('共1条' in dy_page, f"断言失败(验证失败): 期望包含'共1条'，实际得到'{dy}'")



